<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>车队申请结算管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
			    rules: {
			    	deductmoney: {compare:true}
			    },
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		$.validator.addMethod("compare", function(value, element) {
			var bigger = $('#settlemoney').val();
			var smaller = $('#deductmoney').val();
			if(parseFloat(bigger) - parseFloat(smaller) > 0.0001){
				return true;
			} else {
				return false;
			}
		}, "扣减金额不能大于结算金额");
		
		function change(){
			var settlemoney = $('#settlemoney').val();
			var deductmoney = $('#deductmoney').val();
		 	var rcptmoney = parseFloat(settlemoney) - parseFloat(deductmoney);
			$('#rcptmoney').val(rcptmoney.toFixed(2));
	    }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/ordersettle/tOrdersSettle/">车队申请结算列表</a></li>
		<li class="active"><a href="${ctx}/ordersettle/tOrdersSettle/confirmform?id=${tOrdersSettle.settleid}">确认开票</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="tOrdersSettle" action="${ctx}/ordersettle/tOrdersSettle/confirmsave" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="settleid"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">申请机构：</label>
			<div class="controls">
				<input type="text" value="${tOrdersSettle.officeid.name}" readonly class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">结算金额：</label>
			<div class="controls">
				<form:input path="settlemoney" htmlEscape="false"  readonly="true" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">开票金额：</label>
			<div class="controls">
				<form:input path="rcptmoney" htmlEscape="false"  readonly="true" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">扣减金额：</label>
			<div class="controls">
				<form:input path="deductmoney" htmlEscape="false"  class="input-xlarge money" onchange="change()"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">扣减理由：</label>
			<div class="controls">
				<form:input path="deductreason" htmlEscape="false"  class="input-xlarge"/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="ordersettle:tOrdersSettle:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="确认开票"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>